//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Diagnostics;
using System.IO;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class RkRecord : CellValueRecord
    {
        private RKNumber _value;

        public RkRecord(double value, Cell cell, BiffWriterWorkbookContext context): base (cell, context)
        {
            Contract.Requires(RKNumber.CanEncode (value));
            _value = (RKNumber)value;
        }

        public RkRecord()
        {
        }


        protected override void WriteValue(BinaryWriter writer)
        {
            _value.Write(writer);
        }

        protected override void ReadValue(BinaryReader reader, int length)
        {
            _value.Read(reader);
            Contract.Assert(length == 4);
            //\\base.ReadContent(reader, length);
        }

        protected override object GetValue(BiffReaderWorkbookContext context)
        {
            return (double)_value;
        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.RK; }
        }
    }
}